package com.whisperarts.financer.app.actions;

import org.eclipse.jface.action.Action;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.ISelectionListener;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction;
import org.eclipse.ui.plugin.AbstractUIPlugin;

import com.whisperarts.financer.app.Application;
import com.whisperarts.financer.app.views.CategoryView;

public class ShowCategoryViewAction extends Action implements 
ISelectionListener, IWorkbenchAction {

	private final IWorkbenchWindow window;
	public final static String ID = "com.whisperarts.financer.app.actions.showCategoryView";
	private IStructuredSelection selection;


	public ShowCategoryViewAction(IWorkbenchWindow window) {
		this.window = window;
		setId(ID);
		setText("&Show categories");
		setToolTipText("Show categpries view");
		setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(Application.PLUGIN_ID, ISharedImages.IMG_OBJS_INFO_TSK));
		window.getSelectionService().addSelectionListener(this);
		setEnabled(true);
	}

	@Override
	public void selectionChanged(IWorkbenchPart part, ISelection incoming) {
	}

	@Override
	public void dispose() {
		window.getSelectionService().removeSelectionListener(this);
	}

	@Override
	public void run() {
		ActionsFactory.showView(CategoryView.ID);
	}
}
